package com.hkts.naturalgasauthentication.base.vo;

import com.hkts.naturalgasauthentication.base.entity.User;
import com.hkts.naturalgasauthentication.mobile.entity.UserMobiles;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * @ClassNameUserVo
 * @Description
 * @Author yck
 * @Date2021-05-11 10:31
 * @Version V1.0
 **/
@ApiModel(description = "用于封装user和电话的工具类")
@Data
public class UserVo implements Serializable {
    private static final long serialVersionUID = -6957361951748382519L;
    @ApiModelProperty("货主id")
    private String userId;
    @ApiModelProperty("昵称")
    private String nickName;
    @ApiModelProperty("头像")
    private String avatar;
    @ApiModelProperty("电话集合")
    private List<String> mobiles;

    /*  public UserVo(User user, List<UserMobiles> list){
          this.avatar=user.getAvatar();
          this.nickName=user.getNickName();
          this.userId=user.getId();
          mobiles=new ArrayList<String>();
          mobiles.add(user.getMobile());
          if(list.size()>0){
              list.stream().forEach(userMobiles -> {
                  mobiles.add(userMobiles.getMobile());
              });
          }

      }*/
    public static UserVo getUserVo(User user, List<UserMobiles> list) {
        UserVo vo = new UserVo();
        vo.setAvatar(user.getAvatar());
        vo.setUserId(user.getId());
        vo.setNickName(user.getNickName());
        List<String>  mobiles=new ArrayList<String>();
        mobiles.add(user.getMobile());
        if(list!=null&&list.size()>0){
            list.stream().forEach(userMobiles -> {
                mobiles.add(userMobiles.getMobile());
            });
        }
        vo.setMobiles(mobiles);
        return vo;
    }
}
